﻿using System;

namespace IFD2
{
    public partial class OfficeAvailFares : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["ACL"].ToString().IndexOf("SB2") < 0)
                {
                    Response.Redirect("unauthorized.aspx");
                }

                hidIpaddr.Value = Request.UserHostAddress.ToString();

                if (Session["AIRLINE"].ToString().IndexOf("*") < 0)//中立代理
                {
                    lstAirline2.SelectedValue = Session["AIRLINE"].ToString();
                    //lstAirline.Enabled = false;
                }

                if (Session["FLT_DATE"] != null)
                    txtFltdate.Text = Convert.ToDateTime(Session["FLT_DATE"].ToString()).ToShortDateString();
                if (Session["ORI"] != null)
                    txtOri.Text = Session["ORI"].ToString();
                if (Session["DES"] != null)
                    txtDes.Text = Session["DES"].ToString();

            }
            txtOri.Attributes.Add("onkeyup", "auto_suggest('MainContent_txtOri',event)");
            txtDes.Attributes.Add("onkeyup", "auto_suggest('MainContent_txtDes',event)");
            txtOri.Attributes.Add("onkeydown", "key_down(event)");
            txtDes.Attributes.Add("onkeydown", "key_down(event)");
            txtOri.Attributes.Add("autocomplete", "off");
            txtDes.Attributes.Add("autocomplete", "off");
        }

        protected void lbtnQuery_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime.Parse(txtFltdate.Text);
            }
            catch
            {
                lblError.Text = "Invalid date format!";
                txtFltdate.Text = "";
                return;
            }
            txtOri.Text = txtOri.Text.Trim().ToUpper();
            txtDes.Text = txtDes.Text.Trim().ToUpper();

            Session["FLT_DATE"] = txtFltdate.Text;
            Session["ORI"] = txtOri.Text;
            Session["DES"] = txtDes.Text;

            GridView1.DataBind();
        }
    }
}